package com.dynamixsoftware.printershare.snmp;

import java.io.ByteArrayOutputStream;
import java.util.Arrays;

public class SNMPOctetString
  extends SNMPObject
{
  protected byte[] data;
  protected byte tag = 4;
  
  public SNMPOctetString()
  {
    this.data = new byte[0];
  }
  
  public SNMPOctetString(String paramString)
  {
    this.data = paramString.getBytes();
  }
  
  public SNMPOctetString(byte[] paramArrayOfByte)
  {
    extractFromBEREncoding(paramArrayOfByte);
  }
  
  private String hexByte(byte paramByte)
  {
    int i = paramByte;
    if (i < 0) {
      i += 256;
    }
    String str1 = new String();
    String str2 = str1 + Integer.toHexString(i / 16);
    return str2 + Integer.toHexString(i % 16);
  }
  
  public boolean equals(Object paramObject)
  {
    if (paramObject == null) {
      return false;
    }
    if (!getClass().equals(paramObject.getClass())) {
      return false;
    }
    SNMPOctetString localSNMPOctetString = (SNMPOctetString)paramObject;
    return Arrays.equals((byte[])getValue(), (byte[])localSNMPOctetString.getValue());
  }
  
  protected void extractFromBEREncoding(byte[] paramArrayOfByte)
  {
    this.data = new byte[paramArrayOfByte.length];
    for (int i = 0; i < paramArrayOfByte.length; i++) {
      this.data[i] = paramArrayOfByte[i];
    }
  }
  
  protected byte[] getBEREncoding()
  {
    ByteArrayOutputStream localByteArrayOutputStream = new ByteArrayOutputStream();
    byte[] arrayOfByte = SNMPBERCodec.encodeLength(this.data.length);
    localByteArrayOutputStream.write(this.tag);
    localByteArrayOutputStream.write(arrayOfByte, 0, arrayOfByte.length);
    localByteArrayOutputStream.write(this.data, 0, this.data.length);
    return localByteArrayOutputStream.toByteArray();
  }
  
  public Object getValue()
  {
    return this.data;
  }
  
  public int hashCode()
  {
    int i = 0;
    for (int j = 0; j < this.data.length; j++)
    {
      int n = i + this.data[j];
      int i1 = n + (n << 10);
      i = i1 ^ i1 >> 6;
    }
    int k = i + (i << 3);
    int m = k ^ k >> 11;
    return m + (m << 15);
  }
  
  public void setValue(Object paramObject)
    throws SNMPBadValueException
  {
    if ((paramObject instanceof byte[]))
    {
      this.data = ((byte[])paramObject);
      return;
    }
    if ((paramObject instanceof String))
    {
      this.data = ((String)paramObject).getBytes();
      return;
    }
    throw new SNMPBadValueException(" Octet String: bad object supplied to set value ");
  }
  
  public String toHexString()
  {
    StringBuffer localStringBuffer = new StringBuffer();
    for (int i = 0; i < this.data.length; i++) {
      localStringBuffer.append(hexByte(this.data[i]) + " ");
    }
    return localStringBuffer.toString();
  }
  
  public String toString()
  {
    return new String(this.data);
  }
}


/* Location:           C:\Users\Admin\Desktop\Decompiler\JAD\jd-gui-0.3.6.windows\classes_dex2jar.jar
 * Qualified Name:     com.dynamixsoftware.printershare.snmp.SNMPOctetString
 * JD-Core Version:    0.7.0.1
 */